import tkinter as tk
from tkinter import messagebox

# 定义服装部件选项
clothes_options = {
    "上衣": ["T恤", "衬衫", "毛衣"],
    "裤子": ["牛仔裤", "运动裤", "西装裤"],
    "鞋子": ["运动鞋", "皮鞋", "凉鞋"]
}

# 初始化角色装扮
current_outfit = {
    "上衣": None,
    "裤子": None,
    "鞋子": None
}

def change_clothes(category):
    def select_cloth(cloth):
        current_outfit[category] = cloth
        sub_window.destroy()
        show_current_outfit()

    sub_window = tk.Toplevel(root)
    sub_window.title(f"选择 {category}")
    for cloth in clothes_options[category]:
        tk.Button(sub_window, text=cloth, command=lambda c=cloth: select_cloth(c)).pack()

def show_current_outfit():
    outfit_text = "当前装扮：\n"
    for category, cloth in current_outfit.items():
        if cloth:
            outfit_text += f"{category}: {cloth}\n"
        else:
            outfit_text += f"{category}: 未选择\n"
    messagebox.showinfo("当前装扮", outfit_text)

# 创建主窗口
root = tk.Tk()
root.title("换装游戏")

# 创建换装按钮
for category in clothes_options:
    tk.Button(root, text=f"更换 {category}", command=lambda c=category: change_clothes(c)).pack()

# 创建查看当前装扮按钮
tk.Button(root, text="查看当前装扮", command=show_current_outfit).pack()

# 运行主循环
root.mainloop()